/*
 * Copyright 2013-2015 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xdtech.sys.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.FilterRule;


/**
 * 
 * @author max.zheng
 * @create 2015-3-22下午7:00:34
 * @since 1.0
 * @see
 */
public class FilterRuleItem implements Serializable{
	private static final long serialVersionUID = 2674438443383308868L;
	private String field;
	private String option;
	private String type;
	private String value;
	public String getField() {
		return field;
	}
	public void setField(String field) {
		this.field = field;
	}
	public String getOption() {
		return option;
	}
	public void setOption(String option) {
		this.option = option;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static FilterRuleItem createItem(FilterRule filterRule) {
		FilterRuleItem filterRuleItem = new FilterRuleItem();
		BeanUtils.copyProperties(filterRuleItem, filterRule);
		//自定义属性设置填充
		return filterRuleItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<FilterRuleItem> createItems(List<FilterRule> filterRules) {
		List<FilterRuleItem> filterRuleItems = new ArrayList<FilterRuleItem>();
		for (FilterRule filterRule : filterRules) {
			filterRuleItems.add(createItem(filterRule));
		}
		return filterRuleItems;
	}
}
